<template>
    <view class="myMessage">
        <Navigation title="我的消息" background="#fff" rightType="read" />
        <view class="bg mb-20 ph-32 pv-32 w-f" v-for="(item, index) in list" :key="index">
            <view class="yuan w-17 h-17 b-17" v-if="item.readStatus==false"></view>
            <view class="fs-32 text-color4">{{item.content}}</view>
            <view class="fs-24 text-color3 mt-12">{{item.createTime}}</view>
        </view>
    </view>
</template>
<script setup lang="ts">
import { ref,getCurrentInstance } from 'vue';
import { onShow, onReachBottom, onPullDownRefresh } from '@dcloudio/uni-app';
	import { messageCountUnread,messageList,messageAllRead,formatTimestamp } from '@/services/api/index';
	import { useAuthStore } from '@/store/modules/auth';
	const { proxy } = getCurrentInstance();
	const userInfo = ref();
	const authStore = useAuthStore();
const list = ref<any[]>([]);
const curt = ref(0);
const listParams = ref<any>({
    pageNo: 1,
    pageSize: 10,
	groupType:2
 
});
onShow(() => {
    list.value = [];
    listParams.value.pageNo = 1;
    getList();

});

async function getList() {
    const { data } = await messageList(listParams.value);

	data.list.forEach((item: any) => {
	    item.createTime = formatTimestamp(item.createTime)
	});
    list.value = list.value.concat(data.list);
}

//下拉刷新
onPullDownRefresh(() => {
    list.value = [];
    listParams.value.pageNo = 1;
    getList();
});
//上拉加载
onReachBottom(() => {
    listParams.value.pageNo++;
    getList();
});

</script>
<style lang="scss" scoped>
.myMessage {
    background: #f5f5f5;
    min-height: 100vh;
    .bg {
        background: #fff;
        position: relative;
        .yuan {
            background: #ff3b30;
            position: absolute;
            right: 32rpx;
            top: 45rpx;
        }
    }
}
</style>
